package duhosdebuggolok;

import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class ProtoMain {
	
	/*private static Application app = new Application();
	private static boolean levelMake = false;
	private static boolean readyToStart = false;
	public static PrintStream out = System.out;
	private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	
	public static void loadCommands(String fileName){
		try {
			in = new BufferedReader(new FileReader(fileName));
			out.println(fileName + " betoltese sikeres.");
		} catch (FileNotFoundException e) {
			out.println(fileName + " betoltesi hiba!.");
		}
	}
	public static void beginWriteCommands(String fileName){
		try {
			out = new PrintStream(new FileOutputStream(fileName));
			out.println("Eredmeny a kovetkezo fajlba kerul: " + fileName + ".");
		} catch (IOException e) {
		}
	}
	public static void endWriteCommands(){
		out.close();
		out = System.out;
	}
	public static void newGame(){
		app.newGame();
	}
	public static void loadGame(String fileName){
		app.loadGame(fileName);
	}
	public static void saveGame(String fileName){
		app.saveGame(fileName);
	}
	public static void showHighScore(){
		app.showHighScore();
	}
	public static void saveHighScore(){
		app.saveHighScore("player");
	}
	public static void enableRandom(){
		NeedSomeHelp.setRandomIsOn(true);
	}
	public static void disableRandom(){
		NeedSomeHelp.setRandomIsOn(false);
	}
	public static void beginLevel(int levelNumber){
		app.field.randomize(levelNumber, app.anthill, app.antHedgehog);
		levelMake = true;
	}
	public static void endLevel(){
		if(levelMake){
			levelMake = false;
			readyToStart = true;
		ProtoMain.out.println("Szint szerkesztese befejezve.");
		}
	}
	public static void loseLevel(){
		app.player.fireLostGameEvent();
		readyToStart = false;
	}
	public static void winLevel(){
		app.control.fireWinGameEvent();
		readyToStart = false;
	}
	public static void moveAnthill(int x, int y){
		app.anthill.setCoord(new Point(x,y));
		ProtoMain.out.println("A hangyaboly athelyezve az "+x+", "+y+" koordinatara.");
	}
	public static void moveAnthedgehog(int x, int y, int angle){
		app.antHedgehog.setCoord(new Point(x,y));
		app.antHedgehog.setAngle(angle);
		app.antHedgehog.setActive();
		ProtoMain.out.println("A hangyaszsun athelyezve az "+x+", "+y+" koordinatara.");
	}
	public static void createAnt(int x, int y, int angle){
		if(levelMake)
			app.anthill.createAnt(x, y, angle);
	}
	public static void createLionAnt(int x, int y, int radius){
		if(levelMake)
			app.field.createLionAnt(x, y, radius, app.anthill);
	}
	public static void createApple(int x, int y, int radius){
		if(levelMake)
			app.field.createApple(x, y, radius, app.anthill);
	}
	public static void createSugar(int x, int y, int radius){
		if(levelMake)
			app.field.createSugar(x, y, radius, app.anthill);
	}
	public static void createTerrainFeature(int x, int y, int radius, int type){
		if(levelMake)
			app.field.createTerrainFeature(x, y, radius, type, app.anthill, app.antHedgehog);
	}
	public static void toxicPuff(int x, int y){
		app.player.getToxic().puffing(new Point(x, y));
	}
	public static void setToxicRadius(int radius){
		app.player.getToxic().setRadius(radius);
	}
	public static void setToxicNrPuff(int num){
		app.player.getToxic().setNrPuff(num);
	}
	public static void antiSmellPuff(int x, int y){
		app.player.getAntiSmell().puffing(new Point(x, y));
	}
	public static void setAntiSmellRadius(int radius){
		app.player.getAntiSmell().setRadius(radius);
	}
	public static void setAntiSmellNrPuff(int num){
		app.player.getAntiSmell().setNrPuff(num);
	}
	public static void setScore(int amount){
		app.player.setScore(amount);
	}
	public static void buy(String w){
		int what = -1;
		if(w.equals("asRad")) what = 0;
		if(w.equals("tRad")) what = 1;
		if(w.equals("asNr")) what = 2;
		if(w.equals("tNr")) what = 3;
		app.shop.buy(what, app.player.getScore());
	}
	public static void simulate(){
		if(readyToStart)
			app.control.oneTick();
		else
			ProtoMain.out.println("Nem lehet szimulalni!");
	}
	public static void startSimulate(){
		if(readyToStart){
			app.control.startThread();
			ProtoMain.out.println("Szimulalas elkezdve.");
		}
		else{
			ProtoMain.out.println("Nem lehet szimulaciot inditani!");
		}
	}
	public static void stopSimulate(){
		app.control.stopThread();
		ProtoMain.out.println("Szimulalas befejezve.");
	}
	public static void help(){
		try {
			BufferedReader br = new BufferedReader(new FileReader("help.txt"));
			String line = null;
			while ((line=br.readLine())!=null){
				out.println(line);
			}
			br.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		
	}
	public static void exit(){
		//app.exitGame();
	}
	public static void feldolgoz(String s){
		  String parancs[] = s.split(" ");
		  if(parancs[0].equals("loadCommands")) loadCommands(parancs[1]);
		  else if(parancs[0].equals("beginWriteCommands")) beginWriteCommands(parancs[1]);
		  else if(parancs[0].equals("endWriteCommands")) endWriteCommands();
		  else if(parancs[0].equals("newGame")) newGame();
		  else if(parancs[0].equals("loadGame")) loadGame(parancs[1]);
		  else if(parancs[0].equals("saveGame")) saveGame(parancs[1]);
		  else if(parancs[0].equals("showHighScore")) showHighScore();
		  else if(parancs[0].equals("saveHighScore")) saveHighScore();
		  else if(parancs[0].equals("enableRandom")) enableRandom();
		  else if(parancs[0].equals("disableRandom")) disableRandom();
		  else if(parancs[0].equals("beginLevel")) beginLevel(Integer.parseInt(parancs[1]));
		  else if(parancs[0].equals("endLevel")) endLevel();
		  else if(parancs[0].equals("loseLevel")) loseLevel();
		  else if(parancs[0].equals("winLevel")) winLevel();
		  else if(parancs[0].equals("moveAnthill")) moveAnthill(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]));
		  else if(parancs[0].equals("moveAntHedgehog")) moveAnthedgehog(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]), Integer.parseInt(parancs[3]));
		  else if(parancs[0].equals("createAnt")) createAnt(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]), Integer.parseInt(parancs[3]));
		  else if(parancs[0].equals("createLionAnt")) createLionAnt(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]), Integer.parseInt(parancs[3]));
		  else if(parancs[0].equals("createApple")) createApple(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]), Integer.parseInt(parancs[3]));
		  else if(parancs[0].equals("createSugar")) createSugar(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]), Integer.parseInt(parancs[3]));
		  else if(parancs[0].equals("createTerrainFeature")) createTerrainFeature(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]), Integer.parseInt(parancs[3]), Integer.parseInt(parancs[4]));
		  else if(parancs[0].equals("toxicPuff")) toxicPuff(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]));
		  else if(parancs[0].equals("setToxicRadius")) setToxicRadius(Integer.parseInt(parancs[1]));
		  else if(parancs[0].equals("setToxicNrPuff")) setToxicNrPuff(Integer.parseInt(parancs[1]));
		  else if(parancs[0].equals("antiSmellPuff")) antiSmellPuff(Integer.parseInt(parancs[1]), Integer.parseInt(parancs[2]));
		  else if(parancs[0].equals("setAntiSmellRadius")) setAntiSmellRadius(Integer.parseInt(parancs[1]));
		  else if(parancs[0].equals("setAntiSmellNrPuff")) setAntiSmellNrPuff(Integer.parseInt(parancs[1]));
		  else if(parancs[0].equals("setScore")) setScore(Integer.parseInt(parancs[1]));
		  else if(parancs[0].equals("buy")) buy((parancs[1]));
		  else if(parancs[0].equals("simulate")) simulate();
		  else if(parancs[0].equals("startSimulate")) startSimulate();
		  else if(parancs[0].equals("stopSimulate")) stopSimulate();
		  else if(parancs[0].equals("help")) help();
		  else if(parancs[0].equals("exit")) exit();
		  else
			  ProtoMain.out.println("Nincs ilyen parancs: " + parancs[0]);
		 }
	public static void main(String[] args){
		while(true){
			String line = null;
			try {
				line = in.readLine();
				if(line != null) {
					feldolgoz(line);
				} else {
					in.close();
					in = new BufferedReader(new InputStreamReader(System.in));
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}	
	}*/

}

